<?php
/*********************/
/*                   */
/*  会员模块       */
/*   BY voiet        */
/*   2009-8-19更新    */
/*                   */
/*********************/

//require_once( CORE_DIR."/model/trading/mdl.shipping.php" );
class cmd_account extends mdl_account
{

	function check_email( $email, &$message )
	{
			$email = trim( $email );
			if ( !eregi( "^.+@.+\$", $email ) )
			{
					$message = "邮箱输入有误！";
					return false;
			}
			else
			{
					$row = $this->db->selectrow( "select email from sdb_members where email='{$email}'" );
												if ( $row['email'] )
												{
																$message = "该邮箱已被注册!";
																return false;
												}
												else if ( $this->check_email_inuc( $email ) == 1 )
												{
																return true;
												}
												else
												{
																return false;
												}
			}
	}
	
	function check_email_inuc( $email )
	{
			$passport = $this->system->loadmodel( "member/passport" );
			if ( $obj = $passport->function_judge( "checkemail" ) )
			{
						return $obj->checkemail( $email );
			}
			else
			{
						return true;
			}
	}
				
	function getrefer( $uname )
	{
			$row = $this->db->selectrow( "select member_id,refer_id,cpatype,email from sdb_members where uname=\"".$uname."\"" );		
			return $row;
			
	}
	
	function getreferbyid( $uid )
	{
			$row = $this->db->selectrow( "select refer_id from sdb_members where member_id=\"".$uid."\"" );		
			return $row['refer_id'];
			
	}
	
	function checkregip( $ip )
	{
			
		$row = $this->db->selectrow( "select count(member_id) as nums from sdb_members where reg_ip='".$ip."' ");		
		if( $row['nums']<=1)return true;
		else return false;
			
			
	}
	
	function updatecpa( $member_id,$cpatype )
	{
			$sql =  "update sdb_members set cpatype = ".$cpatype." where member_id=\"".$member_id."\"" ;		
			if ( !$this->db->exec( $sql ) )
			{
				return false;
			}
			else return true;
			
	}

}

?>